import numpy as np

def verify_result(data_dir):
    x = np.fromfile(f"{data_dir}/input_x.bin", dtype=np.float32)
    out = np.fromfile(f"{data_dir}/output.bin", dtype=np.int32)
    
    # 计算期望结果 (1-based索引)
    expected_idx = np.argmin(np.abs(x)) + 1
    
    print(f"Computed index: {out[0]}, Expected index: {expected_idx}")
    assert out[0] == expected_idx, "Validation failed!"
    print("Validation passed!")

if __name__ == "__main__":
    verify_result("data")